package com.longshine.arthmetic.question;

import java.util.ArrayList;
import java.util.List;

public class MouseExperiment {

	public static void main(String[] args){
		new MouseExperiment().doExperiment();
	}
	Mouse[] mouse = new Mouse[10];
	Bottle[] bottle = new Bottle[1000];
	public void init(){
		for(int i=0;i<mouse.length;i++){
			mouse[i] = new Mouse();
		}
		for(int i=0;i<bottle.length;i++){
			bottle[i] = new Bottle();
			bottle[i].setPoisonous(false);
		}
	}
	public void doExperiment(){
		init();
		bottle[428].setPoisonous(true);
		for(int i=0;i<mouse.length;i++){
			feed(i);
		}
		System.out.println(toString());
	}
	public void feed(int index){
		int k = (int)Math.pow(2, index);
//		for(int j=0;j<bottle.length;j=j+2*k){
//			for(int i = 0;i<k;i++){
//				mouse[index].addFood(bottle[j]);
//			}
//		}
		for(int j=0;j<bottle.length;j++){
			if((j+1)%k==0){
				mouse[index].addFood(bottle[j]);
			}
		}
	}
	@Override
	public String toString(){
		String rt = "";
		for(int i =0;i<mouse.length;i++){
			rt = mouse[i]+rt;
		}
		return rt;
	}
}


class Mouse{
	List<Bottle> foods = new ArrayList<Bottle>();
	public boolean isDeath() {
		for(int i=0;i<foods.size();i++){
			if(foods.get(i).isPoisonous()){
				return true;
			}
		}
		return false;
	}

	public void addFood(Bottle bottle){
		foods.add(bottle);
	}
	@Override
	public String toString(){
		boolean rt = isDeath();
		return ""+(rt==true?"1":"0");
	}
	
}
class Bottle{
	boolean isPoisonous;
	public boolean isPoisonous() {
		return isPoisonous;
	}
	public void setPoisonous(boolean isPoisonous) {
		this.isPoisonous = isPoisonous;
	}
	public void feed(Mouse mouse){
		mouse.addFood(this);
	}
	@Override
	public String toString(){
		return ""+isPoisonous;
	}
}